from Base.Base import Base
from selenium.webdriver.common.by import By
import time

class Page(Base):
    # 定位元素
    dy1_loc=(By.XPATH,'//*[@id="deepseek-entry"]/div[2]')
    dy2_loc=(By.XPATH,'//*[@id="main"]/div[1]/div/a')

    ssk_loc=(By.XPATH,'//*[@id="query"]')
    dj_loc=(By.XPATH,'//*[@id="stb"]')

    dy3_loc=(By.XPATH,'//*[@id="ad_result_leftup_0"]/div/h4/a/span')
    dy4_loc=(By.XPATH,'//*[@id="ad_result_leftup_1"]/div/h4/a/span')
    dy5_loc=(By.XPATH,'//*[@id="ad_result_leftup_2"]/div/h4/a')
    dy6_loc=(By.XPATH,'//*[@id="main"]/div[4]/div/div[4]/div[1]/h3/a')
    dy7_loc=(By.XPATH,'//*[@id="main"]/div[4]/div/div[5]/div[1]/h3/a')
    dy8_loc=(By.XPATH,'//*[@id="sogou_vr_30010187_title_4"]')
    dy9_loc=(By.XPATH,'//*[@id="main"]/div[4]/div/div[9]/div[1]/h3/a')
    dy10_loc=(By.XPATH,'//*[@id="sogou_vr_30010547_title_7"]/div')
    dy11_loc=(By.XPATH,'//*[@id="main"]/div[4]/div/div[11]/div[1]/h3/a')
    dy12_loc=(By.XPATH,'//*[@id="sogou_vr_30000000_9"]')
    dy13_loc=(By.XPATH,'//*[@id="sogou_vr_30000000_11"]')

    dr_loc=(By.XPATH,'//*[@id="sogou_page_2"]')

    dy1_dr=(By.XPATH,'//*[@id="sogou_vr_30000000_0"]')
    dy2_dr=(By.XPATH,'//*[@id="sogou_vr_30000000_1"]')

    # 搜索框输入‘软件测试自动化’
    def ssk(self):
        self.send_keys(self.ssk_loc,'软件测试自动化')
    # 点击搜索按钮
    def dj(self):
        self.click(self.dj_loc)

    # 断言页面标题
    def dy1(self):
        return self.text(self.dy1_loc)
    # 断言结果页面
    def dy2(self):
        return self.text(self.dy2_loc)


    def dy3(self):
        return self.text(self.dy3_loc)
    def dy4(self):
        return self.text(self.dy4_loc)
    def dy5(self):
        return self.text(self.dy5_loc)
    def dy6(self):
        return self.text(self.dy6_loc)
    def dy7(self):
        return self.text(self.dy7_loc)
    def dy8(self):
        return self.text(self.dy8_loc)
    def dy9(self):
        return self.text(self.dy9_loc)
    def dy10(self):
        return self.text(self.dy10_loc)
    def dy11(self):
        return self.text(self.dy11_loc)
    def dy12(self):
        return self.text(self.dy12_loc)
    def dy13(self):
        return self.text(self.dy13_loc)

    # 第二页
    def dr(self):
        self.click(self.dr_loc)

    def dr14(self):
        return self.text(self.dy1_dr)
    def dr15(self):
        return self.text(self.dy2_dr)

    def test_dog(self):
        self.open_url('https://www.sogou.com/')
        assert self.dy1()=='体验DeepSeek模型专线版'
        print(self.dy1())
        self.ssk()
        self.dj()
        time.sleep(3)
        assert self.dy2()=='全部结果'
        print(self.dy2())

        # assert '软件测试' in self.dy3()
        print(self.dy3())
        # assert '软件测试' in self.dy4()
        print(self.dy4())
        # assert '软件测试' in self.dy5()
        print(self.dy5())
        # assert '软件测试' in self.dy6()
        print(self.dy6())
        # assert '软件测试' in self.dy7()
        print(self.dy7())
        # assert '软件测试' in self.dy8()
        print(self.dy8())

        print('')

        # assert '软件测试' in self.dy9()
        print(self.dy9())
        # assert '软件测试' in self.dy10()
        print(self.dy10())
        # assert '软件测试' in self.dy11()
        print(self.dy11())
        # assert '软件测试' in self.dy12()
        print(self.dy12())
        # assert '软件测试' in self.dy13()
        print(self.dy13())
        self.dr()
        # assert '软件测试' in self.dy14()
        print(self.dr14())
        # assert '软件测试' in self.dy15()
        print(self.dr15())



